<?php
namespace app\common\model;
use think\Model;

class StaffManageModel extends Model{
    protected  $name = 'staff_manage';
    protected  $pk   = 'staff_manage_id';

    public static function onBeforeInsert($model)
    {
        $model->set("create_ip", request()->ip());
    }
    public function user(){
        return $this->hasOne(UserModel::class,'user_id','user_id')->bind(['open_id','user_name','mobile','face']);
    }
    public function staff(){
        return $this->hasOne(StaffModel::class,'staff_id','staff_id')->bind(['name','mobile','position','code']);
    }
    public function staffDetail(){
        return $this->hasOne(StaffDetailModel::class,'staff_id','staff_id')->bind(['face','weixin']);
    }
}
